package com.advertise.strutsAction;

import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;


import org.apache.struts2.ServletActionContext;

import com.advertise.service.MenuService_IFace;
import com.advertise.tool.DhtmlxHelper;



public class MenuAction {
	
	private MenuService_IFace menuService;
	
	public MenuService_IFace getMenuService() {
		return menuService;
	}

	public void setMenuService(MenuService_IFace menuService) {
		this.menuService = menuService;
	}
	
	private String xmlData;			// this is for xml menu



	public String getMenu(){
		
		HttpServletRequest request=ServletActionContext.getRequest();
		
		
		
		/** get the clicked node id and assign it to menuId and then get the sub menus for this node  **/
		int menuId=0;
		
		if(request.getParameter("id")!=null){
			menuId=new Integer(request.getParameter("id"));
		}
		
		
		xmlData=DhtmlxHelper.convertListToTreeData(menuService.getSubMenus(menuId),menuId);
		
		return "success";
		
	}

	public String getXmlData() {
		return xmlData;
	}

	public void setXmlData(String xmlData) {
		this.xmlData = xmlData;
	}


}
